package com.yunfeng.feign.client;

import com.yunfeng.config.GreetingClientConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
//Don't use eureka, use url to locate service.
//@FeignClient(name="GreetingService", url = "localhost:9000")

@FeignClient(name="GreetingService", fallback = GreetingClientFallBack.class, configuration = GreetingClientConfiguration.class)
public interface GreetingClient {
    @RequestMapping(value = "/greetingWord", method = RequestMethod.GET)
    //@HystrixCommand(commandProperties = {
    //    @HystrixProperty(name="circuitBreaker.requestVolumeThreshold",value = "2")
    //})
    public String greetingWord () ;
}

@Component
 class GreetingClientFallBack implements GreetingClient {
    @Override
    public String greetingWord() {
        return "FallBack";
    }
}
